package cn.zc.curriculum.service.controller.curriculum;


import cn.tools.core.VO.PageVO;
import cn.tools.core.base.R;

import cn.zc.curriculum.entity.DOS.QuestionBankDOS;
import cn.zc.curriculum.entity.Dto.QuestionBankDto;
import cn.zc.curriculum.service.service.QuestionBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 题库 前端控制器
 * </p>
 *
 * @author keno
 * @since 2022-02-14
 */
@Api(tags = "练习题接口")
@RestController
@RequestMapping("/curriculum")
public class QuestionBankController {

    @Resource
    private QuestionBankService questionBankService;

    /**
     * 根据目录id查询对应的题库
     * @param pageVO
     * @param menuId
     * @return
     */
    @ApiOperation(value = "根据目录id查询目录下练习题")
    @GetMapping("/find/QuestionBankByMenu")
    private R<Object> findStudentQuestionBankByMenu(PageVO pageVO, String menuId){
        List<QuestionBankDto> byMenu = questionBankService.findQuestionBankByMenu(pageVO, menuId);
        return R.success(byMenu);
    }


    /**
     * 提交练习题作答答案
     */
    @ApiOperation(value = "提交练习题作答")
    @PostMapping("/push/StudentQuestionBank")
    private R<Object> pushStudentQuestionBank(@RequestBody String menuId, List<QuestionBankDOS> questionBankDOS){
        Integer studentScore = questionBankService.pushStudentQuestionBank(menuId,questionBankDOS);
        return R.success(studentScore);
    }

    @ApiOperation(value = "根据目录Id查看学生本次练习题作答")
    @GetMapping("/find/StudentQuestionBank")
    private R<Object> findStudentQuestionBank(PageVO pageVO,String menuId){
        List<QuestionBankDto> questionBankDto = questionBankService.findStudentQuestionBank(pageVO,menuId);
        return R.success(questionBankDto);
    }
}

